﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FTBS.Models.DAO;
using FTBS.Models.Entities;

namespace FTBS.Models.BLO
{
    public class PromotionBLO
    {
        private PromotionDAO _promotionDao = new PromotionDAO();

        /// <summary>
        /// get list of promotions
        /// </summary>
        /// <returns>List of promotions</returns>
        /// <author>hungph</author>
        public List<Promotion> LoadAllPromotions()
        {
            var listPro = _promotionDao.GetAllPromotions();
            return listPro;
        }

        /// <summary>
        /// load Promotions Order By Id
        /// </summary>
        /// <returns>List of promotions</returns>
        /// <author>hungph</author>
        public List<Promotion> LoadPromotionsOrderById()
        {
            var listPro = _promotionDao.LoadPromotionsOrderById();
            return listPro;
        }

        /// <summary>
        /// get a Promotion by ID
        /// </summary>
        /// <returns>Promotion</returns>
        /// <author>hungph</author>
        public Promotion LoadPromotionById(int id)
        {
            var promotion = _promotionDao.LoadPromotionById(id);
            return promotion;
        }

        /// <summary>
        /// create a new promotion
        /// </summary>
        /// <returns>bool</returns>
        /// <author>hungph</author>
        public bool CreatePromotion(Promotion promotion)
        {
            var result = _promotionDao.Add(promotion);
            if (result == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// Edit promotion 
        /// </summary>
        /// <returns>bool</returns>
        /// <author>hungph</author>
        public bool EditPromotion(Promotion promotion)
        {
            var result = _promotionDao.Edit(promotion);
            if (result == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        /// <summary>
        /// delete promotion
        /// </summary>
        /// <returns>bool</returns>
        /// <author>hungph</author>
        public bool DeletePromotion(Promotion promotion)
        {
            var result = _promotionDao.Delete(promotion);
            if (result == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}